package com.example.yuejian.yuejian.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.example.yuejian.yuejian.R;
import com.example.yuejian.yuejian.adapter.MyShowPhotoAdapter;
import com.example.yuejian.yuejian.base.BaseActivity;
import com.example.yuejian.yuejian.base.ModleListListener;
import com.example.yuejian.yuejian.bean.ShowPhotoList;
import com.example.yuejian.yuejian.model.UserModel;

import java.util.List;

public class MyShowPhotoActivity extends BaseActivity {
    private RecyclerView recyclerView;
    private ImageView btn_back;

    private ModleListListener<ShowPhotoList>listModleListListener=new ModleListListener<ShowPhotoList>() {
        @Override
        public void onResponse(List<ShowPhotoList> l) {
            List<ShowPhotoList> res=l;
            recyclerView.setAdapter(new MyShowPhotoAdapter(getApplication(),res));
        }

        @Override
        public void onFail(String msg) {

        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_show_photo);
        initViews();
        back();
    }
    private void initViews()
    { recyclerView=(RecyclerView)findViewById(R.id.id_myshowphoto_list_recycleview);
        // GridLayoutManager gm = new GridLayoutManager(this.getActivity(),2);
        // 网格是的list布局   2列
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        //recyclerView.setLayoutManager(gm);

    }
    private  void getData()
    {
        UserModel userModel=new UserModel();
        userModel.MyShowPhotoList(getUser_id(),listModleListListener);

    }
    private void back()
    {
        btn_back=(ImageView)findViewById(R.id.imgBtn_myshowphoto_list_back);
        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }
    public void onResume() {
        getData();
        super.onResume();

    }

}
